﻿using System;
using System.Windows.Controls;

using SBPweb.Talk.Client.Library;

namespace SBPweb.Talk.Client.Silverlight
{

    public partial class ChatControl : UserControl
    {

        #region Private fields

        private ChatClient client;
        //private SocketClient client;

        #endregion

        #region Constructor logic

        public ChatControl()
        {
            InitializeComponent();
            InitializeClient();
        }

        #endregion

        #region Methods

        private void InitializeClient()
        {
            //client = new SocketClient();
            client = new ChatClient("pintyo.ath.cx", "SBPwebTalk");

            Loaded += new System.Windows.RoutedEventHandler(ChatControl_Loaded);
        }

        #endregion

        #region Event handlers

        #region UI

        private void ChatControl_Loaded(object sender, System.Windows.RoutedEventArgs e)
        {
            client.Connection.SigningIn += new EventHandler(Connection_SigningIn);
            client.Connection.SigningOut += new EventHandler(Connection_SigningOut);
            client.Connection.SignedIn += new EventHandler(Connection_SignedIn);
            client.Connection.SignedOut += new EventHandler(Connection_SignedOut);
            //client.MessageReceived += new EventHandler<MessageEventArgs>(client_MessageReceived);
            //client.Connect();
            client.Connection.SignIn("szunyi", "Pa55W0rd");
        }

        //private void client_MessageReceived(object sender, MessageEventArgs e)
        //{
        //    tbIncoming.Text += string.Format("[{0}]: {1}\r\n", e.Stamp, e.Message);
        //}

        private void Button_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            //client.SendMessage(tbOutgoing.Text);
        }

        #endregion

        #region Client

        private void Connection_SigningIn(object sender, EventArgs e)
        {

        }

        private void Connection_SignedIn(object sender, EventArgs e)
        {

        }

        private void Connection_SigningOut(object sender, EventArgs e)
        {

        }

        private void Connection_SignedOut(object sender, EventArgs e)
        {

        }

        #endregion

        #endregion

    }

}